import { defaultOptions, renderAsync } from 'docx-preview'

const VueWrapper = (el) => ({
  $el: el,
  $destroy() {
    // 什么也不需要 nothing to do
  }
})
export default async function render(buffer, target) {
  const docxOptions = Object.assign(defaultOptions, {
    debug: true,
    experimental: true
  })
  await renderAsync(buffer, target, null, docxOptions)
  return VueWrapper(target)
}
